package com.daylightrobbery.server.packet.room;


import com.daylightrobbery.server.GameManager;
import com.daylightrobbery.server.entity.Room;
import com.daylightrobbery.server.packet.type.DataPacket;
import com.daylightrobbery.server.packet.type.MulticastDataPacket;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
public class AddRoomPacket implements MulticastDataPacket {

    private static final Logger log = LoggerFactory.getLogger(AddRoomPacket.class);

    private String uid;
    private Integer roomId;
    private int type = 20006;

    @Override
    public DataPacket process() {
        log.info("Start Inter Room...");
        log.info("Inter Room finished");
        Room room = GameManager.getInstance().addPlayerToRoom(uid, roomId);
        return new ShowRoomPacket().setRoom(room);
    }

    @Override
    public int getType() {
        return type;
    }

    public String getUid() {
        return uid;
    }

    public AddRoomPacket setUid(String uid) {
        this.uid = uid;
        return this;
    }

    public Integer getRoomId() {
        return roomId;
    }

    public AddRoomPacket setRoomId(Integer roomId) {
        this.roomId = roomId;
        return this;
    }

    @Override
    public String toString() {
        return "CreateRoomPacket{" +
                "uid='" + uid + '\'' +
                '}';
    }

}
